import { get, post } from '@/utils/request.js'
import Config from '@/config'

export default {
  getLeadsRecords: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetLeadsRecords', {
      ClientOrgID: id
    })
  },
  getLeadPhase: leadId => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetLeadsPhase', {
      LeadsID: leadId
    })
  },
  getClientContacts: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetClientContacts', {
      ClientOrgID: id
    })
  },
  checkNextPhaseIsAvailable: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/NextPhaseIsAllow', {
      ClientOrgID: id
    })
  },
  addTouchRecord: (id, data) => {
    data.clientOrgID = id
    return post(Config.API_VERSION + '/TargetClients/PhaseProgress/AddClientLeadsTouch', data)
  },
  getTouchRecords: (id, leadId) => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetPhaseRecords', {
      ClientOrgID: id,
      LeadsID: leadId
    })
  },
  getLastContact: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetLastestContacts', {
      clientOrgID: id
    })
  },
  restart: (id, data) => {
    data.clientOrgID = id
    return post(Config.API_VERSION + '/TargetClients/PhaseProgress/RestartClientLeadsTouch', data)
  },
  // 是否具备转正基础条件
  isCanTransit: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetIsCanTransit', { ClientOrgID: id })
  },
  // 是否可以转正
  isAllowTransit: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/ClientIsAllowTransit', { clientOrgID: id })
  },
  transit: id => {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/ClientPhaseTransit', {
      ClientOrgID: id
    })
  },
  // 获取单条记录详细信息
  getTouchRecord: (leadId, recordId) => {
    return get(
      Config.API_VERSION +
        '/TargetClients/PhaseProgress/GetClientLeadsTouchRecord?leadsID=' +
        leadId +
        '&leadsTouchID=' +
        recordId,
      {}
    )
  },
  updateTouchRecord: (id, recordId, data) => {
    data.clientOrgID = parseInt(id)
    data.leadsTouchID = parseInt(recordId)
    return post(Config.API_VERSION + '/TargetClients/PhaseProgress/UpdateClientLeadsTouch', data)
  }
}
